export const toCamelCase = (str) => {
  return str.replace(/_(\w)/g, (all, letter) => letter.toUpperCase());
};

export const toPascalCase = (str) => {
  return toCamelCase(str).replace(/^(\w)/, (all, letter) => letter.toUpperCase());
};

export const upperCaseToCamelCase = (str) => {
  return toCamelCase(str.toLowerCase());
};

export const titleCase = (word) => {
  return word.substring(0, 1).toUpperCase() + word.substring(1);
};

export const dateFormat = (date, format = 'yyyy-MM-dd') => {
  let fullYear = date.getFullYear();
  let month = date.getMonth() + 1;
  let dd = date.getDate();
  return format
    .replace(/yyyy/g, fullYear)
    .replace(/MM/g, month < 10 ? '0' + month : month)
    .replace(/dd/g, dd < 10 ? '0' + dd : dd);
};
